﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--[if IE 6 ]><html class="ie6"><![endif]-->
<!--[if IE 7 ]><html class="ie7"><![endif]-->
<html>
<head>
<title>修改收货信息窗口</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />


<script type="text/javascript" src="../../scripts/jquery/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="../../scripts/lhgdialog/lhgdialog.js?skin=idialog_1"></script>
<script type="text/javascript" src="../../scripts/jquery/PCASClass.js"></script>
<script type="text/javascript" src="../../admin/js/layout.js"></script>
<link href="../../admin/skin/default/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">

  var api = frameElement.api, W = api.opener;
    api.button({
        name: '确定',
        focus: true,
        callback: function () {
            submitForm();
            return false;
        }
    }, {
        name: '取消',
        callback: function () {
            location.reload(true);
        }
    });
 //页面加载完成执行
    $(function () {
        new PCAS("txtProvince", "txtCity", "txtArea", "北京市");
      
  
      
  });
</script>
  


</head>

<body><div  style="display:none;">
<div id="container"></div>
</div>
<div class="div-content1">
    <dl>
      <dt>收件人姓名</dt>
      <dd><input type="text" id="txtAcceptName" class="input txt" /> <span class="Validform_checktip">*</span></dd>
    </dl>
    <dl>
      <dt>所属省市</dt>
      <dd>
        <select id="txtProvince"  disabled="disabled" name="txtProvince" class="select"></select>
        <select id="txtCity" name="txtCity" class="select"></select>
        <select id="txtArea" name="txtArea" class="select"></select>
      </dd>
    </dl>
    <dl>
      <dt>详细地址</dt>
      <dd><input type="text" id="txtAddress" class="input normal1"  onblur="ptOutPolygon1()"/> <span class="Validform_checktip">*</span><a href="javascript:void(0)"  onclick="ptOutPolygon();">验证地址</a></dd>
    </dl>
    <dl>
      <dt>邮政编码</dt>
      <dd><input type="text" id="txtPostCode" class="input txt" /></dd>
    </dl>
    <dl  >
      <dt>联系手机</dt>
      <dd><input type="text" id="txtMobile" class="input txt" /> <span class="Validform_checktip">*</span></dd>
    </dl>
    <dl style="display:none">
      <dt>联系电话</dt>
      <dd><input type="text" id="txtTelphone" class="input txt" /></dd>
    </dl>
      <dl>
      <dt>默认地址</dt>
      <dd  >
          <input id="status" name="status" type="radio" checked=checked value="1" />是<input id="status1" type="radio" name="status" value="0" />否</dd>
    </dl>
</div>
   <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=OYonZmtvxwM2fzf71C3rrZvB&services=&t='+(new Date()).getTime()"></script>
<script type="text/javascript" src="http://api.map.baidu.com/library/GeoUtils/1.2/src/GeoUtils_min.js"></script>
<script type="text/javascript">
    //窗口API
    var myGeo = new BMap.Geocoder();

    pts = [new BMap.Point(116.230249, 39.995418),
new BMap.Point(116.215302, 39.881233),
new BMap.Point(116.232549, 39.848448),
new BMap.Point(116.269344, 39.815646),
new BMap.Point(116.284292, 39.781054),
new BMap.Point(116.311887, 39.783716),
new BMap.Point(116.377428, 39.77928),
new BMap.Point(116.399275, 39.76242),
new BMap.Point(116.438369, 39.789038),
new BMap.Point(116.488961, 39.812099),
new BMap.Point(116.525756, 39.832492),
new BMap.Point(116.555652, 39.853765),
new BMap.Point(116.547603, 39.943218),
new BMap.Point(116.487812, 40.017524),
new BMap.Point(116.440669, 40.024597),
new BMap.Point(116.341783, 40.025481),
new BMap.Point(116.283142, 40.013988),
new BMap.Point(116.2291, 39.997186)];
    var ply = new BMap.Polygon(pts);
    var fild = 0;
  
   

    //提交表单处理
    function submitForm() {
        //验证表单
      
        if ($("#txtAcceptName").val() == "") {
            W.$.dialog.alert('请填写收货人姓名！', function () { $("#txtAcceptName").focus(); }, api);
            return false;
        }
        if ($("#txtArea").val() == "") {
            W.$.dialog.alert('请选择所在地区！', function () { $("#txtProvince").focus(); }, api);
            return false;
        }
        if ($("#txtAddress").val() == "") {

           


            
            W.$.dialog.alert('请填写详细的送货地址！', function () { $("#txtAddress").focus(); }, api);
            return false;
        }
         if ($("#txtPostCode").val() == "") {





            W.$.dialog.alert('请填写邮政编码！', function () { $("#txtAddress").focus(); }, api);
            return false;
        }
        if (fild != 0) {
            W.$.dialog.alert('只配送五环内的订单！', function () { $("#txtAddress").focus(); }, api);
            return false;
        }
        if ($("#txtMobile").val() == "" && $("#txtTelphone").val() == "") {
            W.$.dialog.alert('请填写联系手机！', function () { $("#txtMobile").focus(); }, api);
            return false;
        }
        //下一步，AJAX提交表单
        var postData = {
            "order_no": $("#spanOrderNo", W.document).text(), "edit_type": "edit_accept_info",
            "accept_name": $("#txtAcceptName").val(), "province": $("#txtProvince").val(),
            "city": $("#txtCity").val(), "area": $("#txtArea").val(), "address": $("#txtAddress").val(),
            "post_code": $("#txtPostCode").val(), "mobile": $("#txtMobile").val(), "telphone": $("#txtTelphone").val(), status: $('input:radio[name="status"]:checked').val(),"field1":fild
        };
        //发送AJAX请求
        W.sendAjaxUrl(api, postData, "../../tools/submit_ajax.ashx?action=accept_address_add");
        return false;
    }
    


    

  
    
    //;
    
    


</script>

<script type="text/javascript">



    function ptOutPolygon1() {

        var keyword = $("#txtAddress").val();
        if (keyword == "") {
            return;
        }
        myGeo.getPoint(keyword, function (poi) {
            if (poi) {

                var result = BMapLib.GeoUtils.isPointInPolygon(poi, ply);
                if (result == false) {
                    
                     fild = 50;
                }
                else {
                    fild = 0;
                }


            }
            else {
                fild = 0;
            }
            return poi;
        }, "北京");

    }
   

    function ptOutPolygon() {

        var keyword = $("#txtAddress").val();
        if (keyword == "") {
            return;
        }
        myGeo.getPoint(keyword, function (poi) {
            if (poi) {

                var result = BMapLib.GeoUtils.isPointInPolygon(poi, ply);
                if (result == false) {
                   W.$.dialog.tips("您的地址在五环外，只配送五环内的订单！", 4, "32X32/succ.png");
                  //  W.$.dialog.alert('', function () { $("#txtAddress").focus(); }, api);
                    return false;
                    // fild = 0;
                }
                else {
                    W.$.dialog.tips("您的地址是五环内", 4, "32X32/succ.png");
                   // W.$.dialog.alert('您的地址是五环内', function () { $("#txtAddress").focus(); }, api);
                    return false;
                }


            }
            else {
                W.$.dialog.alert('请输入正确的地址！', function () { $("#txtAddress").focus(); }, api);
                return false;
            }
            return poi;
        }, "北京");
        
    }
</script>

</body>


</html>